package com.hao.DaoImpl;
import  com.hao.Dao.productjsqDao;
import com.hao.entity.productjsq;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.hao.util.BaseDao;

/**
 * Created by Administrator on 2018/8/6.
 */
public class productjsqImpl implements  productjsqDao {
    @Override
    public List<productjsq> finduser(int wpid) {
        List<productjsq> list=new ArrayList<productjsq>();
        String sql="SELECT * FROM product where 1=1";
        if(wpid!=-1){
            sql+=" and wpid=?";
        }
        Connection conn=null;
        PreparedStatement state=null;

        ResultSet rs=null;
        try {
            conn=BaseDao.getConnection();
            state=conn.prepareStatement(sql);
            if(wpid!=-1){
                state.setInt(1,wpid);
            }
            rs=state.executeQuery();
            while(rs.next()){
                productjsq mm=new productjsq();

            mm.setWpid(rs.getInt("wpid"));
            mm.setWaterName(rs.getString("waterName"));
            list.add(mm);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            BaseDao.closeConnection(conn, state, rs);
        }
        return list;
    }
}
